<template>
    <div class="content">
        <top-bar/>
        <cms-swiper/>
        <div class="news-content">
            <div class="content-title">{{content.title}}</div>
            <div class="content-tip">
                <div class="content-tips-author">作者：{{content.author}}</div>
                <div class="content-tips-time">发布时间：{{content.createTime}}</div>
                <div class="content-text">
                    <div class="txt" v-html="content.text">
                        {{content.text}}
                    </div>
                </div>

            </div>
        </div>
    </div>

</template>

<script>
    import noticeApi from '@/api/noticeApi'
    import newsApi from '@/api/newsApi'
    import topBar from '@/components/topbar/TopBar'
    import cmsSwiper from "@/components/swiper/CmsSwiper";
    export default {
        name: "Content",
        components:{
            topBar,cmsSwiper
        },
        data(){
            return{
                content:{
                    title:'',
                    author:'',
                    createTime:'',
                    text:'',
                }
            }
        },
        created:async function(){
            let query = this.$route.query
            if (query.type == 'notice'){
                let res = await noticeApi.noticeDetail(query.id);
                if (res.code == '200'){
                    let content={
                        title:res.data[0].noticeTitle,
                        author:res.data[0].createBy,
                        createTime:res.data[0].createDate,
                        text:res.data[0].noticeContent,
                    }
                    this.content = content
                }
            }
            if (query.type == 'news'){
                let res = await newsApi.newsDetail("",query.id);
                if (res.code == '200'){
                    let content={
                        title:res.data[0].newsTitle,
                        author:res.data[0].createBy,
                        createTime:res.data[0].createDate,
                        text:res.data[0].newsContent,
                    }
                    this.content = content
                }

            }
        }
    }
</script>

<style>
    .content >.news-content{
        width: 70%;
        margin-left: 15%;
        margin-top: 100px;
    }
    .content >.news-content > .content-title{
        text-align: center;
        font-size: 25px;
        font-weight: bold;
        margin-top: 30px;
    }
    .content >.news-content > .content-tip{
        margin-top: 10px;
    }
    .content-tip >.content-tips-author,.content-tip >.content-tips-time{
        font-size: 14px;
        color: #8c939d;
        text-align: center;
    }
    .content-tip > .content-text{
        text-align: left;
        line-height: 40px;
        margin-top: 50px;
        margin-bottom: 300px;
    }
    .txt > * > img{
        margin-left: 10%;
        width: 80%;
        height: 500px;
    }

</style>